package org.wavefar.securityconfig.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author summer
 * @date 2021/4/23 下午7:11
 */
@RestController
public class HelloController {
    @Value("${server.port}")
    Integer port;
    @GetMapping("/hello")
    public String hello(){
        return String.format("hello world port:%s",port);
    }

    @RequestMapping("/s")
    public String success()
    {
        return "success";
    }

    @GetMapping("/admin/hello")
    public String admin() {
        return "admin";
    }

    @GetMapping("/user/hello")
    public String user() {
        return "user";
    }

    @GetMapping("/rememberme")
    public String rememberme() {
        return "rememberme";
    }

    @GetMapping("/set")
    public String set(HttpSession session) {
        session.setAttribute("blog", "http://aliyun.52it.club");
        return String.valueOf(port);
    }
    @GetMapping("/get")
    public String get(HttpSession session) {
        return String.format("当前服务端口号:%s,blog:%s",port,session.getAttribute("blog"));
    }
}
